package a.client.lib_main.ui.splash

import a.client.lib_common.constant.RouteUrl
import a.client.lib_common.ui.BaseActivity
import a.client.lib_main.databinding.MainSplashActivityBinding
import androidx.lifecycle.lifecycleScope
import com.alibaba.android.arouter.facade.annotation.Route
import com.alibaba.android.arouter.launcher.ARouter
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import me.jessyan.autosize.internal.CancelAdapt

/**
@author:jacky
@Date:2021/1/21
启动页
 **/
@Route(path = RouteUrl.SplashActivity)
class SplashActivity :
    BaseActivity<MainSplashActivityBinding, SplashViewModel>(SplashViewModel::class.java),
    CancelAdapt {

    override fun initViewBinding() = MainSplashActivityBinding.inflate(layoutInflater)


    override fun initView() {
        jumpMain()
    }


    /**
     * 延时跳转到首页
     */
    private fun jumpMain() {
        lifecycleScope.launch(Dispatchers.Default) {
            delay(1000L)
            ARouter.getInstance()
                .build(RouteUrl.MainActivity)
                .navigation()
            delay(100L)
            finish()
        }
    }


    override fun initViewObserve() {}

}